<include file="Public/min-header"/>
<div class="wrapper">
	<include file="Public/breadcrumb"/>

    <!-- Main content -->
    <section class="content">
        <!-- Main content -->
        <div class="container-fluid">
            <div class="pull-right">
                <a href="javascript:history.go(-1)" data-toggle="tooltip" title="" class="btn btn-default" data-original-title="返回"><i class="fa fa-reply"></i></a>
            	<a href="javascript:;" class="btn btn-default" data-url="http://www.tp-shop.cn/Doc/Index/article/id/190/developer/phper.html" onclick="get_help(this)"><i class="fa fa-question-circle"></i> 帮助</a>
            </div>
            <div class="panel panel-default">
                <div class="panel-heading">
                    <h3 class="panel-title"><i class="fa fa-list"></i>插件列表</h3>
                </div>
                <div class="panel-body">
                    <ul class="nav nav-tabs">
                        <li class="active"><a id="tab_plugin_payment" href="#tab_pay" data-toggle="tab">支付插件</a></li>
                        <!--                        <li><a href="#tab_goods_desc" data-toggle="tab">描述信息</a></li>-->
                        <li><a id="tab_plugin_login" href="#tab_login" data-toggle="tab">登录插件</a></li>
                        <li><a id="tab_plugin_shipping" href="#tab_shipping" data-toggle="tab">物流插件</a></li>
                        <li><a id="tab_plugin_function" href="#tab_function" data-toggle="tab">功能插件</a></li>
                        <!--<li><a href="#tab_cloud" data-toggle="tab">云插件</a></li>-->
                        <li style="display: none;"><a href="http://www.tp-shop.cn/articleList_cat_id_30.html" target="_blank">云插件</a></li>
                        
                    </ul>
                    <!--表单数据-->
                    <form method="post" id="addEditGoodsForm">

                        <div class="tab-content">
                            <!--支付插件-->
                            <div class="tab-pane active" id="tab_pay">
                                <div class="row">
                                    <volist name="payment" id="p">
                                        <div class="col-sm-2">
                                            <div class="thumbnail">
                                                <img  style="width:150px; height:60px;" src="/plugins/payment/{$p.code}/{$p.icon}" alt="...">
                                                <div class="caption">
                                                    <h4>{$p.name}</h4>
                                                    <p>{$p.desc}</p>
                                                    <if condition="$p.status eq 0">
                                                        <p><a onclick="installPlugin('{$p.type}','{$p.code}',1)" href="#" class="btn btn-primary" role="button">一键安装</a> </p>
                                                        <else />
                                                        <p><a onclick="installPlugin('{$p.type}','{$p.code}',0)" href="#" class="btn btn-danger" role="button">卸载</a>
                                                            <a href="{:U('Admin/Plugin/setting',array('type'=>$p['type'],'code'=>$p['code']))}" class="btn btn-primary" role="button">配置</a>
                                                        </p>

                                                    </if>
                                                </div>
                                            </div>
                                        </div>
                                    </volist>


                                </div>
                            </div>
                            <!--支付插件-->

                            <!-- 登录插件-->
                            <div class="tab-pane" id="tab_login">
                                <div class="row">
                                    <volist name="login" id="l">
                                        <div class="col-sm-2">
                                            <div class="thumbnail">
                                                <img style="width:150px; height:60px;" src="/plugins/login/{$l.code}/{$l.icon}">
                                                <div class="caption">
                                                    <h4>{$l.name}</h4>
                                                    <p>{$l.desc}</p>
                                                    <if condition="$l.status eq 0">
                                                        <p><a onclick="installPlugin('{$l.type}','{$l.code}',1)" href="#" class="btn btn-primary" role="button">一键安装</a> </p>
                                                        <else />
                                                        <p><a onclick="installPlugin('{$l.type}','{$l.code}',0)" href="#" class="btn btn-danger" role="button">卸载</a> <a href="{:U('Admin/Plugin/setting',array('type'=>$l['type'],'code'=>$l['code']))}" class="btn btn-primary" role="button">配置</a></p>
                                                    </if>
                                                </div>
                                            </div>
                                        </div>
                                    </volist>
                                </div>
                            </div>
                            <!--登录插件-->
                            <!-- 物流插件-->
                            <div class="tab-pane" id="tab_shipping">
                                <div class="row">
                                    <volist name="shipping" id="l">
                                        <div class="col-sm-2"  style="width:260px;">
                                            <div class="thumbnail">
                                                <img style="width:150px; height:60px;" src="/plugins/shipping/{$l.code}/{$l.icon}">
                                                <div class="caption">
                                                    <h4>{$l.name}</h4>
                                                    <p>{$l.desc}</p>
                                                    <if condition="$l.status eq 0">
                                                        <p>
                                                            <a onclick="installPlugin('{$l.type}','{$l.code}',1)" href="#" class="btn btn-primary" role="button">一键安装</a>
                                                            <a onclick="if(confirm('确定要删除吗?')) del_shipping('{$l['code']}');" href="#" class="btn btn-danger" role="button"><i class="fa fa-trash-o"></i></a>
                                                        </p>
                                                        <else />
                                                        <p>
                                                            <a onclick="installPlugin('{$l.type}','{$l.code}',0)" href="#" class="btn btn-danger" role="button">卸载</a>
                                                            <a href="{:U('Admin/Plugin/shipping_list',array('type'=>'shipping','code'=>$l['code']))}" class="btn btn-primary" role="button">配置</a>
                                                            <a href="{:U('Admin/Plugin/shipping_print',array('type'=>'shipping','code'=>$l['code']))}" class="btn btn-primary" role="button">模板编辑</a>
                                                        </p>
                                                    </if>
                                                </div>
                                            </div>
                                        </div>
                                    </volist>
                                    <div style="width:260px;" class="col-sm-2">
                                        <div class="thumbnail" style="height:203px;">
                                            <img src="__PUBLIC__/images/wuliu.png" style="width:150px; height:100px;">
                                            <div class="caption">
                                                <p></p>
                                                <p></p>
                                                <p align="center">
                                                    <a class="btn btn-primary" href="/Admin/Plugin/add_shipping">添加物流</a>
                                                </p>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                            <!-- 物流插件-->
                            <!-- 功能插件-->
                            <div class="tab-pane" id="tab_function">
                            <div class="row">
                                    <volist name="function" id="l">
                                        <div class="col-sm-2"  style="width:260px;">
                                            <div class="thumbnail">
                                                <img style="width:150px; height:60px;" src="/plugins/function/{$l.code}/{$l.icon}">
                                                <div class="caption">
                                                    <h4>{$l.name}</h4>
                                                    <p>{$l.desc}</p>
                                                    <if condition="$l.status eq 0">
                                                        <p><a onclick="installPlugin('{$l.type}','{$l.code}',1)" href="#" class="btn btn-primary" role="button">一键安装</a> </p>
                                                        <else />
                                                        <p>
                                                            <a onclick="installPlugin('{$l.type}','{$l.code}',0)" href="#" class="btn btn-danger" role="button">卸载</a>                                                                                                                        
                                                        </p>
                                                    </if>
                                                </div>
                                            </div>
                                        </div>
                                    </volist>
                                </div>
                            </div>
                            <!-- 功能插件-->

                            <!-- 云插件-->
                            <div class="tab-pane" id="tab_cloud">
                                <table class="table table-bordered" id="goods_attr_table">
                                    <tr>
                                        <td>暂无:</td>
                                        <td>
                                            暂无
                                        </td>
                                    </tr>
                                </table>
                            </div>
                            <!-- 云插件-->
                        </div>

                    </form><!--表单数据-->
                </div>
            </div>
        </div>    <!-- /.content -->
    </section>
    <!-- /.content -->
</div>
<script>
    $(document).ready(function(){
        var type = "{$type}";
        if(type !== ''){
            $('#tab_plugin_'+type).trigger('click');
        }
    });

    // 删除物流
    function del_shipping(code)
    {
        $.ajax({
            type : "POST",
            url:"{:U('Admin/Plugin/del_shipping')}",//+tab,
            dataType: "json",
            data : {code:code},
            success: function(data){
                layer.alert(data.msg, {icon: 2} ,function(index){
                    layer.close(index);
                    //location.href = location.href;
                    location.reload();
                });

            }
        });
    }

    //插件安装(卸载)
    function installPlugin(type,code,type2){

        var url = '/index.php?m=Admin&c=Plugin&a=install&type='+type+'&code='+code+'&install='+type2;

        $.get(url,function(data){
            var obj = JSON.parse(data);
            alert(obj.msg);
            //layer.alert(obj.msg, {icon: 2});  
            if(obj.status == 1){
                window.location.href='/index.php?m=Admin&c=Plugin&a=index&type='+type;
            }
        })
    }

</script>
</body>
</html>